/**
 * @param {character[][]} board
 * @return {boolean}
 */
 var isValidSudoku = function(board) {
  let row = [...Array(9)].map(() => Array(9).fill(false));
  let col = [...Array(9)].map(() => Array(9).fill(false));
  let sub = [...Array(9)].map(() => Array(9).fill(false));
  for (let i = 0; i < 9; ++i) {
      for (let j = 0; j < 9; ++j) {
          const num = board[i][j].charCodeAt() - '1'.charCodeAt();
          if (num < 0 || num > 9) {
              continue;
          }
          const k = Math.floor(i / 3) * 3 + Math.floor(j / 3);
          if (row[i][num] || col[j][num] || sub[k][num]) {
              return false;
          }
          row[i][num] = true;
          col[j][num] = true;
          sub[k][num] = true;
      }
  }
  return true;
};